package com.youle.youleservice.greedao;

import android.content.Context;

/**
 * Created by zhoubigbo on 2017/6/21.
 */
public class DBHelper {

    static DaoSession daoSession;

    private static DaoSession getDBSession(Context ctx){
        if (daoSession==null){
            ctx = ctx.getApplicationContext();
            DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(ctx, "yl.db", null);
            DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
            daoSession = daoMaster.newSession();
        }
        return daoSession;
    }


    public static ProvinceDao getProvinceDao(Context ctx){
        return getDBSession(ctx).getProvinceDao();
    }


    public static CityDao getCityDao(Context ctx){
        return getDBSession(ctx).getCityDao();
    }


    public static LocationDao getLocationDao(Context ctx){
        return getDBSession(ctx).getLocationDao();
    }




}
